#!/bin/bash

###############################################
###### IRIS-Processor #########################
###############################################

# This script processes an iris-database the following way
# Input Image 	=> Segmentation result (<filename>.png)
#		=> Iris code	       (<filename>.png)


SRCAGE=$4
SENSOR=$5
TARGET=res/$SENSOR/$SRCAGE

SRC=$TARGET/ic

TARGET_IC=$TARGET/dist
TOOLDIR=bin

SEGMENT=$1
TOOL=$2
DIST=$3

 # Clean up
mkdir -p $TARGET_IC

# Segmentations that are available


  
  
      OUTFILE=$TARGET_IC/$SEGMENT_$TOOL.txt
      rm -rf $OUTFILE
	FILELIST=`ls $SRC/$SEGMENT/$TOOL`
      
      echo 'F1','F2','distance', > $OUTFILE
      
     
      #echo $FILELIST
      
  
       
	for F in $FILELIST
       do
	  echo $SEGMENT/$TOOL ': Processing distances to ' $F
	  for FF in $FILELIST
	  do
	  
	      RES=`$TOOLDIR/$DIST -i $SRC/$SEGMENT/$TOOL/$F $SRC/$SEGMENT/$TOOL/$FF` 
	      
	      IFS='=' read -a PARTS <<< "$RES"
	      
	      
	      echo $F,$FF,${PARTS[1]} >> $OUTFILE
	  
	  done
       done
       
      

